package com.daily.pump.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;

import com.daily.pump.R;
import com.xunxi.mimi.ui.base.BaseActivity;

/**
 * 作者: liyu on  2017/11/15 0015 14:29
 * 功能描述:
 * 备注:
 */
public class SplashActivity extends BaseActivity {

    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState, String tag) {

    }

    @Override
    protected void initView() {
        setStatusBarTintResource(R.color.transparent);
    }

    @Override
    protected void initPresenter() {

    }

    @Override
    protected void initValue() {
        if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            return;
        }
        if (mHandler == null){
            mHandler = new Handler();
        }
        mHandler.postDelayed(mRunnable, 1500);
    }

    private Runnable mRunnable = new Runnable() {
        @Override
        public void run() {
            Bundle bundle = getIntent().getExtras();
            if (bundle != null) {
                startIntent(MainActivity.class, bundle);
                finish();
            } else {
                startIntentAndFinish(MainActivity.class);
            }
        }
    };

    @Override
    protected void onDestroy() {
        super.onDestroy();

        if (mHandler != null) {
            mHandler.removeCallbacks(mRunnable);
        }
    }

}
